/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;
import com.mysql.jdbc.CallableStatement;
import controlo.MovimentoBean;
import controlo.util.Conexao;
import java.sql.Date;
import java.sql.SQLException;
/**
 *
 * @author bruno
 */
public class MovimentoDao extends Conexao {

    public MovimentoDao() {
        super();
    }

    
    public void registarMovimentoUnico(MovimentoBean mov) throws ClassNotFoundException, SQLException
    {
        
         CallableStatement cStmt = (CallableStatement) getConnection().prepareCall("{call registarMovimentoUnico(?, ?, ?, ?, ?, ?, ?, ?)}");
         cStmt.setString("descr", mov.getDescr());
         cStmt.setString("tipoMov", mov.getTipoMov());
         
         cStmt.setInt("codDoc", mov.getCodDoc());
         cStmt.setInt("idConta", mov.getIdConta());
         cStmt.setInt("idMoeda", mov.getIdMoeda());
         cStmt.setInt("idLog", mov.getIdFuncionario());

         cStmt.setDouble("valorMov", mov.getValorMov());
         cStmt.setDate("dataDoc", new Date(mov.getDataDoc().getTime()) );
     
         cStmt.execute();
    }
    
    public void registarMovimentoDuplo(MovimentoBean mov) throws ClassNotFoundException, SQLException
    {
        
         CallableStatement cStmt = (CallableStatement) getConnection().prepareCall("{call registarMovimentoDuplo(?, ?, ?, ?, ?, ?, ?, ?, ?,?)}");
         cStmt.setString("descr", mov.getDescr());
         cStmt.setString("tipoMov", mov.getTipoMov());
         
         cStmt.setInt("codDoc", mov.getCodDoc());
         cStmt.setInt("idConta", mov.getIdConta());
         cStmt.setInt("idMoeda", mov.getIdMoeda());
         
         cStmt.setInt("idConta2", mov.getIdConta2());
         cStmt.setInt("idMoeda2", mov.getIdMoeda2());
         
         cStmt.setInt("idLog", mov.getIdFuncionario());

         cStmt.setDouble("valorMov", mov.getValorMov());
         cStmt.setDate("dataDoc", new Date(mov.getDataDoc().getTime()) );
     
         cStmt.execute();
    }
   
}
